<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Object isValid = request.getSession().getAttribute("userIsValid");
    if (isValid == null || Boolean.valueOf(isValid.toString()) != true) {
        request.getRequestDispatcher("login.html").forward(request, response);
    }
%>
<html>
<head>
    <title>Title</title>
    <script src="../js/jquery.3.4.1.js" type="text/javascript"></script>

    <script type="text/javascript">
        function submitData() {
            var userName = $("#userName").val();
            var uerPassword = $("#userPassword").val();
            var rePassword = $("#rePassword").val();
            if (!userName || !uerPassword) {
                alert('用户名或密码不能为空！');
                return false;
            }
            if (uerPassword != rePassword) {
                alert('密码确认错误！');
                return false;
            }
            //提交数据
            return true;
        }
    </script>
</head>
<body>
<form onsubmit="return submitData();" id="form1" name="form1" method="post" action="/user?type=insert">
    <table>
        <tr>
            <th>用户名：</th>
            <td>
                <input id="userName" name="userName" type="text"/>
            </td>
        </tr>
        <tr>
            <th>密码：</th>
            <td>
                <input id="userPassword" name="userPassword" type="password"/>
            </td>
        </tr>
        <tr>
            <th>确认密码：</th>
            <td>
                <input id="rePassword" name="rePassword" type="password"/>
            </td>
        </tr>
        <tr>
            <th></th>
            <td>
                <input id="submitBtn" name="submitBtn" type="submit"/>
            </td>
        </tr>
    </table>
</form>
</body>
</html>
